/* 
 * @(#)BPConfiguration.java  1.0 2008-8-12
 * 
 * Copyright 2008 Kepler-Delaware.  All rights reserved.
 */
package com.os.util;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

//import com.delaware.be.jle.util.BPConstants;
/**
 * Get parameters from property file.
 * 
 * @author David
 */
public class BPConfiguration implements Serializable {

	private static final long serialVersionUID = 1L;

	static Properties businessProperties = null;

	public static String getString(String name) {
		return name;
	}
	/**
	 * 默认年度
	 * @return
	 */
	public static int getYear_default() {
		return BPConstants.DEF_YEAR;
	}
	
	/**
	 * 取公司名称
	 * @return
	 */
	public static String getCom_name() {
		getProperties();
		return businessProperties.getProperty(
				BPConstants.Com_Name).trim();
		//return BPConstants.Com_Name;
	}
	/**
	 * 每个页面的标题名称
	 * @return
	 */
	public static String getSys_title() {
		getProperties();
		return businessProperties.getProperty(
				BPConstants.sys_title).trim();
		//return BPConstants.Com_Name;
	}
	/**
	 * Get properties.
	 * 
	 * @return Properties
	 */
	public static synchronized Properties getProperties() {
		try {
			if (businessProperties == null) {
				String resource = BPConfiguration
						.getString("osConfig.properties");
				businessProperties = ClassLoaderUtil.getProperties(resource);
			}
		} catch (BPException e) {
			e.printStackTrace();
		}
		return businessProperties;
	}
	
	/**
	 * 文件根目录
	 * @return
	 */
	public static String getPathBase() {
		return getProperty("path_base");
	}


	/**
	 * 按属性名称提取属性值
	 */
	public static String getProperty(String name) {
		try {
			getProperties();
			return businessProperties.getProperty(
					name).trim();
		} catch (Exception e) {
			return "";
		}
	}

	public static void main(String [] args){
		System.out.println(BPConfiguration.getPathBase());
		//System.out.println(  new BPConfiguration().getCom_name() );
		//Tools.printList(new BPConfiguration().getHrefList());
		//System.out.println(  new BPConfiguration().getHrefList() );

	}
	
}
